################################
#
#     Makefile ASSEGNAMENTO 2 AA 2015/16
#    
################################

#file che verranno inseriti nel tar finale
FILE_DA_CONSEGNARE=percolation.c

# preferenze compilatore e flag di compilazione
CC=gcc
CFLAGS= -Wall -pedantic -g
objects= percolation.o percolation_docenti.o

# phony targets
.PHONY: cleanall test1 test2 test3


mat1 : test_one.o $(objects)
	gcc $(objects) test_one.o -o mat1

mat2 : test_two.o $(objects)
	gcc $(objects) test_two.o -o mat2

mat3 : test_three.o $(objects)
	gcc $(objects) test_three.o -o mat3


test_one.o: test_one.c percolation.h
test_two.o: test_two.c percolation.h
test_three.o: test_three.c percolation.h


percolation.o: percolation.c percolation.h
percolation_docenti.o: percolation_docenti.c percolation.h

cleanall: 
	-rm -f *.o *~ ./core ./mat*



test1:
	rm -fr out1.txt dati1.txt out1.check
	cp DATA/dati1.txt .
	cp DATA/out1.check .
	chmod 644 dati1.txt
	chmod 644 out1.check
	make cleanall
	make mat1
	./mat1
	diff out1.txt out1.check
	@echo "********** Test1 superato!"

test2:
	rm -fr out2.txt dati2.txt out2.check
	cp DATA/dati2.txt .
	cp DATA/out2.check .
	chmod 644 dati2.txt
	chmod 644 out2.check
	make cleanall
	make mat2
	./mat2
	diff out2.txt out2.check
	@echo "********** Test2 superato!"

test3: 
	rm -fr out3.txt dati3.txt out3.check
	cp DATA/dati3.txt .
	cp DATA/out3.check .
	chmod 644 dati3.txt
	chmod 644 out3.check
	make cleanall
	make mat3
	./mat3
	diff out3.txt out3.check	
	@echo "********** Test3 superato!"

consegna:
	make clean
	make test1
	make test2
	make test3
	./gruppo-check.pl < gruppo.txt
	tar -cvf $(USER)-a2.tar ./gruppo.txt  $(FILE_DA_CONSEGNARE) 
	@echo "********** TAR creato inviare in allegato a una mail a \nsusanna.pelagatti@unipi.it insieme a nome, cognome,  numero di matricola e corso di apprtenenza (A/B)"
